﻿Imports System.Data
Partial Class Form_RptApproveNon
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.AddHeader("Cache-control", "no-store, must-revalidate, private,no-cache")
        Response.AddHeader("Pragma", "no-cache")
        Dim dsApp As DataSet = Nothing
        Dim cls As New clsDatabase
        Dim clsFormatDate As New clsDateFormat
        Dim strCustType As String = Request.Item("CUSTTYPE")
        Dim strStartDate As String = Request.Item("STARTDATE")
        Dim strEndDate As String = Request.Item("ENDDATE")
        Dim strSql As String = ""
        Dim UserRight As clsSessionMenuRight
        UserRight = Session("clsMenuRight")

        Dim strWhere As String = ""

        strSql = "select l.*,c.THFIRSTNAME,c.THMIDNAME,c.THLASTNAME," _
                           & " c.ENFIRSTNAME, c.ENMIDNAME, c.ENLASTNAME," _
                           & " c.CUSTTYPE, c.UNIQUEID, c.CUSTCODE," _
                           & " c.AMLCDD, c.AMLREASON, c.AMLCDDOVERVIEW, c.AMLREASONOVERVIEW, " _
                           & " s.APPROVENAME APPROVESTATUS" _
                           & " from " & System.Configuration.ConfigurationSettings.AppSettings("TableLog_Approve") & " l " _
                           & " left join " & System.Configuration.ConfigurationSettings.AppSettings("TableMCUSTOMER") & " c on l.CUSTSEQ = c.CUSTSEQ " _
                           & " left join " & System.Configuration.ConfigurationSettings.AppSettings("TableMAPPROVESTATUS") & " s on l.ApproveCode=s.ApproveCode " _
                           & " where c.CUSTTYPE = :prmCUSTTYPE " _
                           & " and l.APPROVENO= :prmAPPROVENO " _
                           & " and l.APPROVEDATE >= :prmAPPROVEDATEStart and l.APPROVEDATE <= :prmAPPROVEDATEEnd " _
                           & " order by l.APPROVEDATE desc "


        If Not (strSql = "") Then
            With SqlDataSource1
                .SelectCommand = strSql

                .SelectParameters.Add(":" + "prmCUSTTYPE", strCustType)
                .SelectParameters.Add(":" + "prmAPPROVENO", UserRight.getUserName)

                Dim aDate As Date = clsFormatDate.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.En, strDateIsChk:=strStartDate)
                Dim bDate As Date = clsFormatDate.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.En, strDateIsChk:=strEndDate)
                .SelectParameters.Add(":" + "prmAPPROVEDATEStart", System.Data.DbType.Date, aDate.ToString("yyyy/MM/dd"))
                .SelectParameters.Add(":" + "prmAPPROVEDATEEnd", System.Data.DbType.Date, bDate.ToString("yyyy/MM/dd"))


                'If (UserRight.getRoleGroup > 59) Then 'Admin เขต 
                '    .SelectParameters.Add(":" + "ZONECODE", UserRight.getZoneCode)
                'ElseIf (UserRight.getRoleGroup > 49) Then 'Admin สาขา
                '    .SelectParameters.Add(":" + "ZONECODE", UserRight.getZoneCode)
                'ElseIf (UserRight.getRoleGroup < 50) Then 'user ทั่วไป
                '    .SelectParameters.Add(":" + "ZONECODE", UserRight.getZoneCode)
                '    .SelectParameters.Add(":" + "CREATEBY", UserRight.getUserName)
                'End If

            End With


        End If


    End Sub
End Class
